package cn.lili.modules.grab.xdxt.service.impl;

import cn.lili.modules.grab.xdxt.config.XdxtConfig;
import cn.lili.modules.grab.xdxt.service.XdxtNoticeService;
import com.alibaba.fastjson.JSONObject;
import com.schl.api.utils.RequestUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.HashMap;

@Component
@Slf4j
public class XdxtNoticeServiceImpl implements XdxtNoticeService {

    @Resource
    private XdxtConfig xdxtConfig;

    /**
     * 订单回调通知接口
     */
    @Override
    public JSONObject orderCallback() {
        HashMap<String, Object> map = new HashMap<>();
        map.put("appid", xdxtConfig.getAppid());
        map.put("secret", xdxtConfig.getSecret());
        JSONObject data = RequestUtil.queryOrderChangeEvent(map, xdxtConfig.getUrl());
        return data;
    }

    /**
     * 商品信息修改通知
     */
    @Override
    public JSONObject goodsCallback() {
        HashMap<String, Object> map = new HashMap<>();
        map.put("appid", xdxtConfig.getAppid());
        map.put("secret", xdxtConfig.getSecret());
        JSONObject data = RequestUtil.queryGoodsChangeEvent(map, xdxtConfig.getUrl());
        return data;
    }
}
